from django.shortcuts import render, redirect, get_object_or_404
from .models import Task, TaskLog
from django.views.generic import ListView, CreateView, UpdateView, DeleteView
from django.urls import reverse_lazy
from django.views.generic import DetailView

class TaskLogView(DetailView):
    model = Task
    template_name = 'tasks/task_logs.html'
    context_object_name = 'task'

class TaskListView(ListView):
    model = Task
    template_name = 'tasks/task_list.html'
    context_object_name = 'tasks'

class TaskCreateView(CreateView):
    model = Task
    fields = ['task_type', 'task_id', 'task_title', 'assignee', 'status', 'highlight', 'dev_comment', 'next_action', 'logs']
    template_name = 'tasks/task_form.html'
    success_url = reverse_lazy('task_list')

class TaskUpdateView(UpdateView):
    model = Task
    fields = ['task_type', 'task_id', 'task_title', 'assignee', 'status', 'highlight', 'dev_comment', 'next_action', 'logs']
    template_name = 'tasks/task_form.html'
    success_url = reverse_lazy('task_list')

class TaskDeleteView(DeleteView):
    model = Task
    template_name = 'tasks/task_confirm_delete.html'
    success_url = reverse_lazy('task_list')
